package starter.data;

import java.util.ArrayList;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class LoginGooglePlusTestCases {
	public void runTestCases(ArrayList<String> codeInjection) throws InterruptedException {
		ArrayList<String> webElements = new ArrayList<String>();
		webElements.add("Email");
		webElements.add("Passwd");
		loginGooglePlusSuccesfull(webElements);
	}
	
	private void loginGooglePlusSuccesfull(ArrayList<String> webElements) throws InterruptedException {
		WebDriver driver = new FirefoxDriver();
		driver.get("https://accounts.google.com/ServiceLogin?service=lso&passive=1209600&continue=https://accounts.google.com/o/oauth2/auth?scope%3Dhttps://www.googleapis.com/auth/userinfo.profile%2Bhttps://www.googleapis.com/auth/userinfo.email%2Bhttps://www.googleapis.com/auth/plus.me%2Bhttps://www.googleapis.com/auth/plus.login%26response_type%3Dcode%26access_type%3Doffline%26redirect_uri%3Dhttps://www.snapsation.com/login/google_callback%26approval_prompt%3Dforce%26client_id%3D146203340371-csguec7n3sq68sd067jjoo0togqfo064.apps.googleusercontent.com%26hl%3Den%26from_login%3D1%26as%3D2a3bb040d12a5f7a&ltmpl=popup&shdf=Cq4CCxIRdGhpcmRQYXJ0eUxvZ29VcmwauQEvL2ltYWdlcy1sc28tb3BlbnNvY2lhbC5nb29nbGV1c2VyY29udGVudC5jb20vZ2FkZ2V0cy9wcm94eT91cmw9aHR0cDovL2Nkbi5zbmFwc2F0aW9uLmNvbS9sb2dvLTY0eDY0LnBuZyZjb250YWluZXI9bHNvJmdhZGdldD1hJnJld3JpdGVNaW1lPWltYWdlLyomcmVzaXplX2g9MTIwJnJlc2l6ZV93PTEyMCZub19leHBhbmQ9MQwLEhV0aGlyZFBhcnR5RGlzcGxheU5hbWUaClNuYXBzYXRpb24MCxIGZG9tYWluGgpTbmFwc2F0aW9uDAsSFXRoaXJkUGFydHlEaXNwbGF5VHlwZRoHREVGQVVMVAwSA2xzbyIUKCR-nuhscNUEJOz2tzJHWtIE4yIoATIU2FRPH9aDU1fFAdUut7c7pp3JZv8&sarp=1&scc=1");
		WebElement email = driver.findElement(By.name(webElements.get(0)));
		email.sendKeys("damciodamcio666@gmail.com");
		WebElement password = driver.findElement(By.name(webElements.get(1)));
		password.sendKeys("admin123admin");
		email.submit();
		Thread.sleep(1800);
	    WebElement loginGooglePlusAccessLink = driver.findElement(By.id("submit_approve_access"));
	    loginGooglePlusAccessLink.click();
		Thread.sleep(1800);
	}
}
